<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="public/css/bootstrap.min.css.css">
    <script src="public/js/jquery-3.4.1.min.js"></script>
    <script src="public/js/socket.io.js"></script>
    <title>login</title>
    <script>
        function register(){
            const username = $('#username').val();
            $.get('/register',{ username }, (data) => {
                if(data.result === 0) {
                    location.href = '/chatroom';
                } else {
                    alert(data.msg);
                }

            })
        }
    </script>
</head>

<body>
    <div class="container">
        <div class="row"> 
            <h1>login</h1>
        </div>
        <div class="row">
            <p class="col-md-4">username</p>
            <input class="col-md-8" type ="text" id="username">
        </div> 
        <div class="row">
            <input type="button" class="btn btn-primary" onclick="register()" value="注册">
        </div>
    </div>
</body>

</html>